package com.dhl.fin.api.enums;

import cn.hutool.core.date.DateUtil;
import lombok.Getter;

import java.time.LocalDate;
import java.util.Date;

@Getter
public enum WeekEnum {

    ONE("周一", 2),
    TWO("周二", 3),
    THREE("周三", 4),
    FOUR("周四", 5),
    FIVE("周五", 6),
    SIX("周六", 7),
    SEVEN("周日", 1);

    private String name;

    private int value;

    WeekEnum(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public static String getWeekName(int value) {
        WeekEnum[] values = WeekEnum.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].value == value) {
                return values[i].name;
            }
        }
        return null;
    }

    public static String getWeekNameByDate(Date dateValue) {
        int weekNum = DateUtil.dayOfWeek(dateValue);
        return getWeekName(weekNum);
    }

}
